// mypage/reference/reference.js
var app=getApp();
var util=require("../../utils/util");
var my=require("../../api/my");


Page({
  /* 页面的初始数据*/
  data: {
    rules: ['分享推广码给您的好友扫码。','好友通过您的推广码绑定后，Ta将成为您的下级会员，未来Ta产生的订单佣金您都能获得奖励，并都自动计入您的钱包。'],
    userinfo: '',
    token: '',
    url: ''
  },
  /*生命周期函数--监听页面加载*/
  onLoad: function (options) {
    var that=this;
    that.setData({userinfo:wx.getStorageSync('userinfo'),token:wx.getStorageSync('token')})
    that.get_code();
  },
  preview_image:function(){
    var that=this;
    wx.previewImage({
      urls: [that.data.url],
    })
  },
  get_code:function(){
    var that=this;
    var params={
      id: that.data.userinfo.id,
      pagesPath: 'pages/home/home'
    }
    my.userQRcode(params,that.data.token).then(res=>{
      if(res.data.code==200){
        that.setData({url:res.data.data})
      }
    })
  },
})